package Task1;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        Geilun g =new Geilun("盖伦",255,50);
        Timo t =new Timo("提莫",183,50);
        System.out.println("欢迎来到盖伦暴打提莫小程序！");
        System.out.println("请控制盖伦暴打提莫。");
        System.out.println("敌我数据展示：");
        g.show();
        t.show();
       while(true){
           System.out.println("请选择你要购买的装备。");
           System.out.println(("1-暴风大剑(攻击力+10）  2--锁子甲（防御力+10）  "));
           int choose1 = sc.nextInt();
           if(choose1 !=1 && choose1 !=2) System.out.println("输入错误，请从新输入");
           else if (choose1 ==1){
                int TimoChoose=t.creat();
                if(TimoChoose==1) {
                    while (true){
                        combat1(g,t);
                        if(g.HP==0) {
                            System.out.println("战败！");
                            return;
                        }else if (t.HP==0) {
                            System.out.println("胜利！");
                            return;
                        }
                        TimoCombat3(g,t);
                        if(g.HP==0) {
                            System.out.println("战败！");
                            break;
                        }else if (t.HP==0) {
                            System.out.println("胜利！");
                            break;
                        }
                    }
                }
                else {
                    while (true) {
                        combat2(g, t);
                        if (g.HP == 0) {
                            System.out.println("战败！");
                            return;
                        } else if (t.HP == 0) {
                            System.out.println("胜利！");
                            return;
                        }
                        TimoCombat2(g, t);
                        if (g.HP == 0) {
                            System.out.println("战败！");
                            break;
                        } else if (t.HP == 0) {
                            System.out.println("胜利！");
                            break;
                        }
                    }
                }
               break;
           }
           else{
               int TimoChoose=t.creat();
               if(TimoChoose==1) {
                   while(true) {
                       combat2(g, t);
                       if (g.HP == 0) {
                           System.out.println("战败！");
                           return;
                       } else if (t.HP == 0) {
                           System.out.println("胜利！");
                           return;
                       }
                       TimoCombat2(g, t);
                       if (g.HP == 0) {
                           System.out.println("战败！");
                           break;
                       } else if (t.HP == 0) {
                           System.out.println("胜利！");
                           break;
                       }
                   }
               }
               else {
                   while(true){
                       combat3(g,t);
                       if(g.HP==0) {
                           System.out.println("战败！");
                           break;
                       }else if (t.HP==0) {
                           System.out.println("胜利！");
                           break;
                       }
                       TimoCombat1(g,t);
                       if(g.HP==0) {
                           System.out.println("战败！");
                           break;
                       }else if (t.HP==0) {
                           System.out.println("胜利！");
                           break;
                       }
                   }
               }
               break;
           }
       }

    }
    //两把大剑
    public static void combat1(Geilun g,Timo t){
        Scanner sc =new Scanner(System.in);
        while(true){
            System.out.println("请选择你要使用的技能：");
            System.out.println("1--审判(消耗10MP) 2--德玛西亚之力（消耗30MP）3--普通攻击");
            int choose2 =sc.nextInt();
            if(choose2 !=1 && choose2 !=2 &&choose2!=3) System.out.println("输入错误，请从新输入");
            else if (choose2 ==1){
                if(g.MP<g.skill1Pay){
                    System.out.println("魔力值不足，请重新选择");
                    continue;
                }
                g.weaponSkill1(t);
                break;
            }
            else if(choose2 ==2){
                if(g.MP<g.skill2Pay){
                    System.out.println("魔力值不足，请重新选择");
                    continue;
                }
                g.weaponSkill2(t);
                break;
            }
            else{
                g.weaponAttack(t);
                break;
            }
        }
    }
    //一剑一甲
    public static void combat2(Geilun g,Timo t){
        Scanner sc =new Scanner(System.in);
        while(true){
            System.out.println("请选择你要使用的技能：");
            System.out.println("1--审判(消耗10MP) 2--德玛西亚之力（消耗30MP）3--普通攻击");
            int choose2 =sc.nextInt();
            if(choose2 !=1 && choose2 !=2 &&choose2!=3) System.out.println("输入错误，请从新输入");
            else if (choose2 ==1){
                g.skill1(t);
                break;
            }
            else if (choose2 ==2){
                g.skill2(t);
                break;
            }else {
                g.attack(t);
                break;
            }
        }
    }
    //两甲
    public static void combat3(Geilun g,Timo t){
        Scanner sc =new Scanner(System.in);
        while(true){
            System.out.println("1--审判(消耗10MP) 2--德玛西亚之力（消耗30MP）3--普通攻击");
            int choose2 =sc.nextInt();
            if(choose2 !=1 && choose2 !=2 &&choose2!=3) System.out.println("输入错误，请从新输入");
            else if (choose2 ==1){
                g.armorSkill1(t);
                break;
            }
            else if(choose2 == 2){
                g.armorSkill2(t);
                break;
            }else{
                g.armorAttack(t);
                break;
            }
        }
    }
    //双甲
    public static void TimoCombat1(Geilun g,Timo t){
        while(true){
            int choose2 = t.creat2();
            if (choose2 == 1){
                if(t.MP<t.skill1Pay) continue;
                t.armorSkill1(g);
                break;
            }
            else if(choose2 == 2){
                if(t.MP<t.skill2Pay) continue;
                t.armorSkill2(g);
                break;
            }else if(choose2==3){
                t.armorAttack(g);
                break;
            }
        }
    }
    //一甲一剑
    public static void TimoCombat2(Geilun g,Timo t){
        while(true){
            int choose2 = t.creat2();
            if (choose2 == 1){
                if(t.MP<t.skill1Pay) continue;
                t.skill1(g);
                break;
            }
            else if(choose2 == 2){
                if(t.MP<t.skill2Pay) continue;
                t.skill2(g);
                break;
            }else if(choose2==3){
                t.attack(g);
                break;
            }
        }
    }
    //双剑
    public static void TimoCombat3(Geilun g,Timo t){
        while(true){
            int choose2 = t.creat2();
            if (choose2 == 1){
                if(t.MP<t.skill1Pay) continue;
                t.weaponSkill1(g);
                break;
            }
            else if(choose2 == 2){
                if(t.MP<t.skill2Pay) continue;
                t.weaponSkill2(g);
                break;
            }else if(choose2==3){
                t.weaponAttack(g);
                break;
            }
        }
    }

}
